﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace testing_thing
{
    public class Player : GameEntity
    {
        public Player(string[] ids) : base(ids, true)
        {
            AddIdentifier(new string[] { "Me", "My", "I", "Inventory" });
        }
        private Location inLocation;

        public Location InLocation
        {
            get { return inLocation; }
            set { inLocation = value; }
        }

        public override GameEntity LocateEntity(string id)
        {
            GameEntity result = base.LocateEntity(id);
            if (result == null)
            {
                result = inLocation.LocateEntity(id); 
            }
            return result;
        }
        
    }

    [TestFixture]
    public class PlayerTest
    {
        [Test]
        public void LocateEntityTest()
        {
            Location loc = new Location(new string[] {"place"});
            Player me = new Player(new string[] {"awesome"});
            me.InLocation = loc;
            Item pencil = new Item(new string[] { "pencil" }, false);
            Item pen = new Item(new string[] { "pen" }, false);
            Item bag = new Item(new string[] { "bag" }, true);
            pen.Title = "Pencil";
            pen.Description = "This is a 2B pencil";
            pen.Title = "Pen";
            pen.Description = "This is a red pen";
            bag.Title = "Bag";
            bag.Description = "This is a brown leather bag that can contain stuff";
            me.Title = "Awesome";
            me.Description = "Awesome is an awesome player";
            bag.Inventory.AddItem(pen);
            loc.Inventory.AddItem(bag);
            Assert.AreSame(me, me.LocateEntity("Inventory"));
            Assert.AreSame(me, me.LocateEntity("Me"));
            Assert.AreSame(loc, me.LocateEntity("place"));
            Assert.AreSame(bag, me.LocateEntity("bag"));
            Assert.IsNull(me.LocateEntity("pen"));
        }
    }
}
